package jm.nj.demo07main.demo05;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;

/*
 *斗地主案例
 * 1.准备牌
 * 2.存储牌
 * 3.洗牌
 * 4.发牌
 * 5.看牌
 * */
public class DouDiZhu {
    public static void main(String[] args) {
        //集合牌
        ArrayList<String> poker = new ArrayList<String>();
        //准备牌
        //定义花色
        String[] colors = {"♣", "♠", "♥", "♦"};
        //定义值
        String[] numbers = {"2", "A", "K", "Q", "J", "10", "9", "8", "7", "6", "5", "4", "3"};
        //2.存牌
        poker.add("大王");
        poker.add("小王");
        for (String number : numbers) {
            for (String color : colors) {
                //System.out.print(color + number);
                poker.add(color + number);
            }
        }
//        System.out.println(poker);
        //3.洗牌 Collections 集合中的方法 static void shuffle(List<?> list) 打乱集合中元素的顺序
        Collections.shuffle(poker);
        System.out.println(poker);

        //4.发牌
        ArrayList<String>player01 = new ArrayList<String>();
        ArrayList<String>player02 = new ArrayList<String>();
        ArrayList<String>player03 = new ArrayList<String>();
        ArrayList<String>dipei = new ArrayList<String>();

        for (int i = 0; i < poker.size(); i++) {
            //集中获取牌
            String p = poker.get(i);

            //判断如i>=51发底牌
            if (i>=51){
                dipei.add(p);
            }else if (i%3==0){
                player01.add(p);
            }else if (i%3==1){
                player02.add(p);
            }else if (i%3==2){
                player03.add(p);
            }

        }
        //5.看牌
        System.out.println("玩家1:"+player01);
        System.out.println("玩家2:"+player02);
        System.out.println("玩家3:"+player03);
        System.out.println("底牌:"+dipei);
    }
}
